<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加跟进</title>
    <meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0.maximum-scale=1.0,user-scalable=no" name="viewport">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/bossIndex.css">
    <link rel="stylesheet" href="css/flexible.css">
    <link rel="stylesheet" href="css/vant.css">
    <script src="js/vue/vue.js"></script>
    <script src="js/vue/axios.js"></script>
    <script src="js/jquery.md5.js"></script>
    <script src="js/vue/vant.js"></script>
    <script src="js/glabe.js"></script>
    <script src="js/jquery-3.3.1.min.js"></script>
    <script src="js/fontsize.js"></script>
    <script src="js/jquery.md5.js"></script>
    <script src="js/vue/qs.js"></script>
</head>
<body>
<div class="container_box" id="app">
    <div class="Information_entry">
        <label class="lf">跟进方式</label>
        <div class="rf message padding14" @click="typeShow = true">
            <span style="font-size: 0.14rem;">{{activeMessage ? activeMessage.text : '请选择跟进方式'}}</span>
            <img src="./images/right_icon.png" alt="">
        </div>
        <van-popup 
            v-model="typeShow"
            position="bottom"
        >
            <van-picker show-toolbar :columns="sourceData" value-key="text" @confirm="sourceSelect" @cancel="sourceNo"/>
        </van-popup>
    </div>
    <div class="remark">
        <label class="lf">跟进内容</label>
        <div class="lf width75">
            <textarea rows="6" maxlength="40" placeholder="请输入跟进内容" v-model="content"></textarea>
        </div>
    </div>
    <div class="save">
        <button type="button" @click="submit()">保存</button>
    </div>
</div>
</body>
<script>
var app = new Vue({
    el: '#app',
    data: {
        //会员id
        id:null,
        //方式弹出成
        typeShow:false,
        sourceData:[
            {"text":"电话","value":'0'},
            {"text":"微信","value":'1'},
            {"text":"QQ","value":'2'},
            {"text":"短信","value":'3'},
            {"text":"面谈","value":'4'},
        ],
        //选中的信息
        activeMessage:null,
        //输入框内容
        content:null,
        //判断会员还是访客
        type:null
    },
    created() {
        //获取路由参数
        let id = getUrlQueryString('id');
        let type = getUrlQueryString('type');
        this.id = id;
        this.type = type;
        console.log(type);
        console.log(id);
    },
    methods: {
        //确认按钮
        sourceSelect(val){
            console.log(val);
            this.activeMessage = val;
            this.typeShow = false;
        },
        //取消选中按钮
        sourceNo(){
            this.typeShow = false;
        },
        //保存按钮
        submit(){
            //验证
            if(this.activeMessage == null || this.activeMessage == ''){
                vant.Toast('请选择跟进方式');
                return false;
            }
            if(this.content == null || this.content == ''){
                vant.Toast('请输入跟进内容');
                return false;
            }
            let Uid = this.id;
            let Ftype = this.activeMessage.value;
            let Info = this.content;
            let from = JSON.stringify({
                Uid,
                Ftype,
                Info
            });
            let sign = md5(from);
            let obj = {
                from,
                sign
            }
            //发送请求
            axios.post('mobileapi/boss/follow.php?act=add_follow',Qs.stringify(obj)).then(res=>{
                if(res.data.code == 200){
                    vant.Toast('新增跟进成功');
                    if(this.type == 1){
                        //访客
                        setTimeout(()=>{
                            location.href = "visitorDetails.html?id="+this.id;
                        },1500);
                    }else{
                        //会员
                        setTimeout(()=>{
                            location.href = "memberDetails.html?id="+this.id+"&active=3";
                        },1500);
                    }
                }else{
                    vant.Toast(res.data.msg);
                }
            }).catch(err=>{
                vant.Toast('请求发送失败，请重试');
            })
        }
    },
})
</script>
</html>